/*
 * Copyright (C) 2010 TopCoder Inc., All Rights Reserved.
 */
package com.hercules.xre.protocol.testing.netty.ssl;
import com.hercules.xre.protocol.testing.Helper;
import com.topcoder.util.log.Log;
import com.topcoder.util.log.LogManager;

import java.security.cert.X509Certificate;

import javax.net.ssl.X509TrustManager;

/**
 * <p>
 * Trust manager that accepts any certificate/issuer. No certificate validation logic is provided.
 * </p>
 * <p>
 * <strong>Thread-safety:</strong> This class is thread safe as it has no state.
 * </p>
 * @author TCSDESIGNER, TCSDEVELOPER
 * @version 1.0
*/
public class DummyTrustManager implements X509TrustManager {
    /**
     * <p>
     * Logger that is used to log activities and errors.
     * It is initialized to LogManager.getLog(DummyTrustManager.class.getName()).
     * Can not be null, never changes after initialization.
     * </p>
    */
    private static final Log LOGGER = LogManager.getLog(DummyTrustManager.class.getName());

    /**
     * Default constructor, empty.
    */
    public DummyTrustManager() {
    }

    /**
     * <p>
     * Return list of accepted certificate issuers. Returned array is empty as all certificates
     * should be accepted.
     * </p>
     * @return empty array
    */
    public X509Certificate[] getAcceptedIssuers() {
        final String signature = "DummyTrustManager#getAcceptedIssuers";
        Helper.logEnter(signature, null, null, LOGGER);
        return Helper.logExit(signature, new X509Certificate[0], LOGGER);
    }

    /**
     * <p>
     * Method responsible for validation if client can be trusted, currently no validation is performed.
     * </p>
     * @param chain certificate
     * @param authType authorization type
    */
    public void checkClientTrusted(X509Certificate[] chain, String authType) {
    }

    /**
     * <p>
     * Method responsible for validation if server can be trusted, currently no validation is performed.
     * </p>
     * @param chain certificate
     * @param authType authorization type
    */
    public void checkServerTrusted(X509Certificate[] chain, String authType) {
    }
}

